<template>
	<view class="data-item">
		<view class="order-type">
			<view>设备保养: <text>{{value.apply_no}}</text></view>
			<!-- <view class="type red">待接单</view> -->
			<!-- <view class="type blue">已报修</view>
			<view class="type yellow">巡查异常</view> -->
		</view>
		<view class="order-info">
			<view class="info-item"><view class="key">设备信息：</view>{{value.pd_maintain_task.device_code}}-{{value.pd_maintain_task.device_name}}</view>
			<view class="info-item"><view class="key">保养事项：</view>{{value.pd_maintain_task.standard_name}}</view>
			<view class="info-item"><view class="key">保养时段：</view>{{value.pd_maintain_task.plan_start_date}}至{{value.pd_maintain_task.plan_end_date}}</view>
			<view class="info-item"><view class="key">保养工时：</view>{{value.pd_maintain_task.plan_partorls_time}}分钟</view>
			<!-- <view v-if="item.pd_maintain_task.repair_image" class="info-item"><view class="key"></view>
				<image-list :pics="item.pd_maintain_task.repair_image"></image-list>
			</view> -->
		</view>
		<view v-if="value.pd_maintain_task.status === '10' && $util.getRights().pd_maintain_task_dispatch" class="handle-btn">
			<view @click="acceptTask">派单</view>
		</view>
		<!-- <view v-else-if="value.pd_maintain_task.status === '10' && $util.getRights().pd_maintain_task_register" class="handle-btn">
			<view @click="acceptTask">立即接单</view>
		</view> -->
		<view v-else-if="value.pd_maintain_task.status === '20'" class="handle-btn">
			<view @click="rollbackTaking" v-if="$util.getRights().pd_maintain_task_register || $util.getRights().pd_maintain_task_dispatch">退回接单</view>
			<view @click="done" v-if="$util.getRights().pd_maintain_task_register">立即处理</view>
			<view v-else @click="viewDetail">查看详情</view>
		</view>
		<view v-else-if="value.pd_maintain_task.status === '30'" class="handle-btn">
			<view @click="confirm" v-if="$util.getRights().pd_maintain_task_dispatch">保养确认</view>
			<view v-else @click="viewDetail">查看详情</view>
		</view>
		<!-- <view v-else-if="value.pd_maintain_task.status === '40'" class="handle-btn">
			<view @click="check" v-if="$util.getRights().pd_maintain_task_check">抽查</view>
			<view v-else @click="viewDetail">查看详情</view>
		</view> -->
		<view v-else-if="value.pd_maintain_task.status === '90'" class="handle-btn">
			<view @click="done" v-if="$util.getRights().pd_maintain_task_register">立即处理</view>
			<view v-else @click="viewDetail">查看详情</view>
		</view>
		<view v-else class="handle-btn">
			<view @click="viewDetail">查看详情</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'MaintainTask',
	props:{
		value: {
			type: Object,
			default: ()=>{
				return {}
			}
		}
	},
	data(){
		return {
		}
	},
	created(){
	},
	methods:{
		viewDetail(item){
			console.warn("item: ", item)
			uni.navigateTo({
				url: '/pagesA/facility-upkeep/facility-upkeep-detail?maintainId=' + this.value.pd_maintain_task.maintain_id  //?isInList=true&data='+JSON.stringify(item) + "&eventName=" + eventName
			})
		},
		acceptTask(){
			uni.navigateTo({
				url: '/pagesA/facility-upkeep/facility-upkeep-accept?maintainId=' + this.value.pd_maintain_task.maintain_id//'/?repairId=' + this.value.pd_maintain_task.repair_id //isInList=true&data='+JSON.stringify(this.value)
			})
		},
		done() {
			uni.navigateTo({
				url: '/pagesA/facility-upkeep/facility-upkeep-done?maintainId=' + this.value.pd_maintain_task.maintain_id //isInList=true&data='+JSON.stringify(this.value)
			})
		},
		confirm() {
			uni.navigateTo({
				url: '/pagesA/facility-upkeep/facility-upkeep-confirm?maintainId=' + this.value.pd_maintain_task.maintain_id //isInList=true&data='+JSON.stringify(this.value)
			})
		},
		// check() {
		// 	uni.navigateTo({
		// 		url: '/pagesA/facility-upkeep/facility-upkeep-check?maintainId=' + this.value.pd_maintain_task.maintain_id //isInList=true&data='+JSON.stringify(this.value)
		// 	})
		// },
		rollbackTaking() {
			this.$util.confirm({
				content: "确定要退回当前接单？",
				confirmText: "退回"
			}).then(isConfirm => {
				if (isConfirm) {
					this.$util.post({
						url: "app/pdMaintainTask/rollbackTaking",
						data: {
							maintain_id: this.value.pd_maintain_task.maintain_id
						}
					}).then(res => {
						console.log('22=========refreshPatrolTask')
						uni.$emit('refreshMaintainTask')
						uni.$emit('refreshHomeDataList')
					})
				}
			})
		},
	}
}
</script>

<style lang="scss" scoped>
.data-item{
	// display: flex;
	// margin-bottom: 30rpx;
	.order-type{
		display: flex;
		justify-content: space-between;
		font-size: 28rpx;
		color: #999999;
		>view:first-child{
			font-size: 32rpx;
			font-weight: bolder;
			color: #333333;
		}
	}
	.order-info{
		margin: 30rpx 0;
		.info-item{
			display: flex;
			font-size: 28rpx;
			color: #333333;
			line-height: 50rpx;
			.key{
				min-width: 150rpx;
				font-size: 28rpx;
				color: #999999;
			}
			.info-imgs{
				display: flex;
				flex-wrap: wrap;
				.img-item{
					width: 120rpx;
					height: 120rpx;
					margin: 2rpx 2rpx 0 0;
				}
			}
		}
	}
	.handle-btn{
		border-top: 1px solid #F5F5F5;
		height: 95rpx;
		margin-top: 20rpx;
		display: flex;
		> view{
			height: 95rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 32rpx;
			font-weight: bolder;
			color: #333333;
			flex: 1;
		}
		& :last-child{
			color: #0055FE;
		}
	}
	.target-info{
		flex: 1;
		display: flex;
		padding-bottom: 20rpx;
		.img{
			width: 260rpx;
			height: 295rpx;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}
		.top{
			.name{
				font-size: 28rpx;
				font-weight: bolder;
				color: #333333;
			}
			.desc{
				font-size: 28rpx;
				color: #999999;
				margin-top: 10rpx;
			}
		}
		.fee{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 30rpx;
			.amount{
				font-size: 36rpx;
				color: #FF3737;
			}
			.common-btn{
				height: 60rpx;
				width: 160rpx;
				font-size: 28rpx;
				margin: 0;
			}
		}
	}
}

.type{
	font-size: 24rpx;
	font-weight: bolder;
	padding: 12rpx;
	border-radius: 4rpx;
}
.red{
	color: #FF3737;
	background-color: #FFEFEF;
}
.yellow{
	color: #FF972C;
	background-color: #FFF8EF;
}
.blue{
	color: #2C72FF;
	background-color: rgba($color: #A5C2FF, $alpha: .16);
}
</style>
